package com.anpy.anlibrary.base

import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider
import java.lang.reflect.ParameterizedType

/**
 *Author: 宇
 *Time:2022/3/28 14:45
 *Description:
 */

abstract class BaseAppActivity<B : ViewDataBinding, T : BaseViewModel>(private val view: Int) : LibBaseActivity() {

    lateinit var binding: B

    lateinit var mViewModel: T

    override fun initView() {
        binding = DataBindingUtil.setContentView(this, view)
        val persistentClass = (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[1] as Class<T>
        mViewModel = ViewModelProvider(
            this,
            ViewModelProvider.AndroidViewModelFactory.getInstance(application)
        )[persistentClass]
    }

    open fun push(userId: String, phone: String) {

    }

    override fun initData() {

    }

    override fun afterRequestPermission(requestCode: Int, isAllGranted: Boolean) {

    }

    override fun onPermissionGranted() {

    }
}